use clap::{App, Arg};

mod bilibili;
mod douyu;
mod huya;

#[tokio::main]
async fn main() {
    let matches = App::new("get_real_url")
        .about("get real stream url of broadcast")
        .version("0.0.1")
        .author("wcc <wcc_bugmaker@163.com>")
        .arg(
            Arg::with_name("platform")
                .long("platform")
                .short("p")
                .default_value("bilibili")
                .value_name("platform")
                .required(true)
                .help("douyu, huya, bilibili"),
        )
        .arg(
            Arg::with_name("room_id")
                .long("room_id")
                .short("i")
                .value_name("room_id")
                // .default_value("5684726")
                // .default_value("660001")
                .default_value("6")
                .required(true)
                .help("live room id"),
        )
        .get_matches();

    let platform = matches.value_of("platform").unwrap_or("douyu");
    let room_id = matches.value_of("room_id").unwrap();

    match platform {
        "douyu" => douyu::get_douyu_real_url(room_id).await,
        "huya" => huya::get_huya_real_url(room_id).await,
        "bilibili" => bilibili::get_bilibili_real_url(room_id).await,
        _ => println!("do not support this platform"),
    }
}
